package com.example.administrator.kotlin.adapter

import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.administrator.kotlin.R
import com.example.administrator.kotlin.bean.Newslist
import com.orhanobut.logger.Logger
import org.jetbrains.anko.onClick
import org.jetbrains.anko.toast

/**
 * Created by Administrator on 2018/3/2/002.
 */
class NewsAdapter1(item_news: Int, datas: List<Newslist>?) : BaseQuickAdapter<Newslist, BaseViewHolder>(item_news, datas) {
    override fun convert(holder: BaseViewHolder?, item: Newslist?) {
        Logger.i(item.toString())
        holder?.setText(R.id.tv_content, item?.title)
        holder?.setText(R.id.tv_time, item?.ctime)
        (holder?.getView<ImageView>(R.id.iv_pic))?.onClick { mContext.toast("pic") }
        (holder?.getView<TextView>(R.id.tv_content))?.onClick { mContext.toast("content") }
        Glide.with(mContext)
                .load(item?.picUrl)
                .into(holder?.getView(R.id.iv_pic))
    }
}

